package com.yxcz.model;
// Generated 2016-1-15 17:33:30 by Hibernate Tools 4.3.1.Final

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * Menu generated by hbm2java
 */
@Entity
@Table(name = "menu", catalog = "yxczoa")
public class Menu implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4150167313741377941L;
	private Integer id;
	private String name;
	private String url;
	private String icon;
	private Integer sequence;
	private Boolean status;
	private String remark;
	private Integer level;
	private Set<Role> roles = new HashSet<>();
	private Menu pPenu;  
	private Set<Menu> childMenu =new HashSet<>();  
	private Boolean isleave;
	
	
	 @ManyToOne
	 @JoinColumn(name="pid")   //外键
	 @JsonIgnore
	public Menu getpPenu() {
		return pPenu;
	}

	public void setpPenu(Menu pPenu) {
		this.pPenu = pPenu;
	}

	
	@OneToMany(mappedBy="pPenu",cascade={CascadeType.REMOVE}) 
	@OrderBy("sequence asc")  
	@JsonIgnore
	public Set<Menu> getChildMenu() {
		return childMenu;
	}

	public void setChildMenu(Set<Menu> childMenu) {
		this.childMenu = childMenu;
	}



	public Menu() {
	}

	public Menu(String name, String url, String icon, Integer sequence, Boolean status, String remark,
			Integer level) {
		this.name = name;
		this.url = url;
		this.icon = icon;
		this.sequence = sequence;
		this.status = status;
		this.remark = remark;
		this.level = level;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)

	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}


	@Column(name = "name", length = 50)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "url", length = 250)
	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Column(name = "icon", length = 250)
	public String getIcon() {
		return this.icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	@Column(name = "sequence")
	public Integer getSequence() {
		return this.sequence;
	}

	public void setSequence(Integer sequence) {
		this.sequence = sequence;
	}

	@Column(name = "status")
	public Boolean getStatus() {
		return this.status;
	}

	public void setStatus(Boolean status) {
		this.status = status;
	}

	@Column(name = "remark", length = 65535)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "level")
	public Integer getLevel() {
		return this.level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	@ManyToMany()
	@JsonBackReference
	@JoinTable(name = "role_menu", joinColumns = @JoinColumn(name = "menu_id") , inverseJoinColumns = @JoinColumn(name = "role_id") )
	public Set<Role> getRoles() {
		return roles;
	}

	
	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	@Column(name = "isleave")
	public Boolean getIsleave() {
		return isleave;
	}

	public void setIsleave(Boolean isleave) {
		this.isleave = isleave;
	}

	


}
